<?php
class Exts_Db_Table_PropertyTable extends Exts_Db_Table_Abstract {

	protected $_rowClass = 'Exts_Db_Table_Row_PropertyRow';
	/* protected $_rowsetClass = 'Exts_Db_Table_Rowset_Abstract';*/

	protected $_foreignKey = "foreign_id";	/* Columna id del dueño de las propiedades. */
	protected $_properties = array(); 		/* Propiedades validas. Array de la forma Propiedad => ValorPorDefecto*/

	public function getProperties () {
		return $this->_properties;
	}

	public function findPropertiesFor($foreignId) {
		return $this->fetchAll($this->select()->Where ("$this->_foreignKey = ?" , $foreignId));
	}

	public function createRow(array $data = array(), $defaultSource = null){
		$row = parent::createRow($data, $defaultSource);
		$row->setForeignKey($this->_foreignKey);
	}

	public function getPropertiesMapFor($foreignId) {
		$rowmap = array();
		foreach ($this->getProperties() as $key => $defaultValue){
			$row = $this->createRow();
			$row->setForeignId($foreignId);
			$row->setKey($key);
			$row->setValue($value);
			$rowmap[$key] = $row;
		}
		return $rowmap;
	}

}

